package com.lemon.ai.socket.packets.spiritgame.model.generator;

import java.util.List;

import com.lemon.ai.socket.packets.spiritgame.model.db.MetaData;
import com.lemon.ai.socket.packets.spiritgame.model.dto.Table;
import com.lemon.ai.socket.packets.spiritgame.model.generator.utils.StringUtils;

public class DaoClassPropertiesGenerator extends AbstractGenerator {

	public DaoClassPropertiesGenerator() {
		super("DaoClassPropertiesTemp.txt");
	}

	public String generate(List<Table> tables) {
		String s = "";
		for (int i = 0; i < tables.size(); i++) {
			s += super.temp;
			s = s.
				replace("PACKAGE_NAME",	super.prop.getProperty("package")).
				replace("CLASS_NAME", StringUtils.generateClassName(tables.get(i).getName())).
				replace("CLASS_PARAMETER", StringUtils.generateParameterName(tables.get(i).getName()));
		}
		return s;
	}

	public String generateDaoClassName() {
		return super.prop.getProperty("dir") + "daoclass.properties";
	}

	public static void main(String[] args) {
		MetaData meta = MetaData.getInstance();
		List<Table> tables = meta.getTables();
		DaoClassPropertiesGenerator g = new DaoClassPropertiesGenerator();
		System.out.println(g.generate(tables));
	}

}
